
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.Date;

// 用户管理类
class UserManager {
    private static Map<String, User> users = new HashMap<>();

    static {
        // 初始化默认管理员
        Admin admin = new Admin(
                UUID.randomUUID().toString(),
                "admin",
                "admin123",
                new Date(),
                "13800000000"
        );
        users.put(admin.getUsername(), admin);
    }

    public static void addUser(User user) {
        users.put(user.getUsername(), user);
    }

    public static void deleteUser(String username) {
        users.remove(username);
    }

    public static User getUserByUsername(String username) {
        return users.get(username);
    }

    public static List<User> getAllUsers() {
        return new ArrayList<>(users.values());
    }
}

// 影片管理类
class MovieManager {
    private static List<Movie> movies = new ArrayList<>();

    public static void addMovie(Movie movie) {
        movies.add(movie);
    }

    public static void deleteMovie(String name) {
        movies.removeIf(m -> m.getName().equals(name));
    }

    public static Movie getMovieByName(String name) {
        for (Movie movie : movies) {
            if (movie.getName().equals(name)) {
                return movie;
            }
        }
        return null;
    }

    public static List<Movie> getAllMovies() {
        return movies;
    }
}

// 场次管理类
class ShowManager {
    private static List<Show> shows = new ArrayList<>();

    public static void addShow(Show show) {
        shows.add(show);
    }

    public static void deleteShow(String showId) {
        shows.removeIf(s -> s.getShowId().equals(showId));
    }

    public static Show getShowById(String showId) {
        for (Show show : shows) {
            if (show.getShowId().equals(showId)) {
                return show;
            }
        }
        return null;
    }

    public static List<Show> getShowsByMovie(Movie movie) {
        List<Show> result = new ArrayList<>();
        for (Show show : shows) {
            if (show.getMovie().equals(movie)) {
                result.add(show);
            }
        }
        return result;
    }

    public static List<Show> getAllShows() {
        return shows;
    }
}

// 票管理类
class TicketManager {
    private static Map<String, Ticket> tickets = new HashMap<>();

    public static void addTicket(Ticket ticket) {
        tickets.put(ticket.getTicketId(), ticket);
    }

    public static Ticket getTicketById(String ticketId) {
        return tickets.get(ticketId);
    }

    public static List<Ticket> getTicketsByShow(Show show) {
        List<Ticket> result = new ArrayList<>();
        for (Ticket ticket : tickets.values()) {
            if (ticket.getShow().equals(show)) {
                result.add(ticket);
            }
        }
        return result;
    }
}